package com.example.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.po.Department;
import com.example.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/dept")
@RestController
public class DeptController {
    @Autowired
    private DepartmentService departmentService;
    @RequestMapping("/list")
    public List<Department> list(@RequestParam Integer depttype) {
        QueryWrapper<Department> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("DeptType",depttype);
        return departmentService.list(queryWrapper);
    }

    @RequestMapping("/getbyid")
    public Department getbyid(@RequestParam Integer deptid) {
        return departmentService.getById(deptid);
    }
}
